package com.example.appointment.fragment;

import android.os.Handler;
import android.os.Message;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.example.appointment.R;
import com.example.appointment.adapter.TeachListAdapter;
import com.example.appointment.meta.TeachVO;

import java.util.ArrayList;

import butterknife.Bind;

/**
 * Created by Admin on 2016/8/31.
 */
public class TeachFragment extends BaseFragment {
    @Bind(R.id.fragment_teach_list)
    RecyclerView teachlist;
    private TeachListAdapter adapter;
    private ArrayList<TeachVO> teachVOArrayList = new ArrayList<TeachVO>();

    private int[] imgs = new int[]{R.mipmap.parkour, R.mipmap.run, R.mipmap.dance, R.mipmap.tennis, R.mipmap.table_tennis, R.mipmap.basketball, R.mipmap.roller_skating, R.mipmap.skids, R.mipmap.skating, R.mipmap.pingpang, R.mipmap.golf, R.mipmap.swim, R.mipmap.bike, R.mipmap.football, R.mipmap.badminton, R.mipmap.ski};//项目的图片
    private String[] texts = new String[]{"跑酷", "跑步", "街舞", "网球", "桌球", "篮球", "轮滑", "滑板", "滑冰", "乒乓球", "高尔夫", "游泳", "自行车", "足球", "羽毛球", "滑雪"};//项目的文字
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {

            }
        }
    };

    @Override
    protected void initView() {
        inittitle();
        final GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
        teachlist.setLayoutManager(layoutManager);
        adapter = new TeachListAdapter(getActivity(), mHandler);
        for (int i = 0; i < 16; i++) {
            TeachVO teachVO = new TeachVO();
            teachVO.setItemdraw(imgs[i]);
            teachVO.setItemname(texts[i]);
            teachVOArrayList.add(teachVO);
        }
        adapter.setArrayList(teachVOArrayList);
        teachlist.setAdapter(adapter);
    }

    /**
     * 初始化标题
     */
    private void inittitle() {
        titile.setText("教学");
        backbtn.setVisibility(View.GONE);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_teach;

    }
}
